<PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>YUI IO Timeout and Abort Tests</title>
</head>

<body class="yui3-skin-sam">
<h1>IO Timeout and Abort Tests</h1>

<script type="text/javascript" src="../../../build/yui/yui.js"></script>
<script type="text/javascript">

(function() {
    YUI({
        base: "../../../build/",
        filter: "debug",
        logExclude: {
            attribute: true,
            dom: true,
            node: true,
            event: true,
            base: true,
            widget: true,
            selector: true,
            io:true
        },
        useConsole: true
    }).use("test", "console", "io-base", function(Y) {

        var console = new Y.Console().render(),
			io = new Y.IO();

		function timeout(id, o) {
			Y.Assert.areSame(0, o.status);
			Y.Assert.areSame('timeout', o.statusText);
		}

		function abort(id, o) {
			Y.Assert.areSame(0, o.status);
			Y.Assert.areSame('abort', o.statusText);
		}

		cfg1 = {
			on: {
				complete: timeout,
				failure: timeout
			 }
		};

		cfg2 = {
			on: {
				complete: abort,
				failure: abort
			 }
		};

        var io_timeout = new Y.Test.Case({
            name: 'Timeout Test',
            'test': function() {
				io._evt('complete', { id: 0,  e: 'timeout' }, cfg1);
            }
        });

        var io_abort = new Y.Test.Case({
            name: 'Abort Test',
            'test': function() {
				io._evt('complete', { id: 1, e: 'abort' }, cfg2);
            }
        });

	Y.Test.Runner.add(io_timeout);
	Y.Test.Runner.add(io_abort);
	Y.Test.Runner.run();
});
})();
</script>
</body>
</html>